import { ref, onMounted } from 'vue'
import { getAllCommunityApi, getBuildingApi, getHouseApi } from '@/api/community.js'

// 获取全部小区
export const useAllCommunityList = () => {
  const community = ref([])
  const getCommunityList = async () => {
    const res = await getAllCommunityApi()
    // console.log(res)
    community.value = res.data
  }

  onMounted(() => {
    getCommunityList()
  })

  return community
}
// 菜单文字状态
export const useButtonStatus = () => {
  let stateButtonList = [
    { label: "菜单", value: "menu" },
    { label: "按钮", value: "file" },
  ];
  return stateButtonList;
};


// 获取对应楼栋
export const useBuildingList = async (code) => {
  const res = await getBuildingApi(code)
  return res.data
}

// 获取对应房屋
export const useHouseList = async (code) => {
  const res = await getHouseApi(code)
  return res.data
}

// 性别
export const useGenderList = () => {
  return [
    { label: '男', value: 1 },
    { label: '女', value: 0 }
  ]
}

// 成员类型
export const useMemberList = () => {
  return [
    { label: '业主', value: 1 },
    { label: '家庭成员', value: 2 },
    { label: '租客', value: 3 }
  ]
}

// !获取角色状态  用户状态 广告管理 通知公告状态用这个
export const useRoleStatus = () => {
  const roleStatus = [
    {
      label: '启用', value: 1
    },
    {
      label: '禁用', value: 0
    }
  ]
  return roleStatus
}

// 车位使用性质
export const carUseStatus = () => {
  const carStatus = [
    {
      label: '售', value: 1
    },
    {
      label: '租', value: 0
    }
  ]
  return carStatus
}



// 获取活动状态
export const useActivityStatus = () => {
  const activityStatus = [
    {
      label: '有效', value: 1
    },
    {
      label: '无效', value: 2
    }
  ]
  return activityStatus
}
// 获取保修状态
export const useRepairStatus = () => {
  const repairStatus = [
    {
      label: '待受理', value: 0
    },
    {
      label: '已受理', value: 1
    },
    {
      label: '已维修', value: 2
    },
  ]
  return repairStatus
}
// 投诉管理
export const useComplainStatus = () => {
  const complainStatus = [
    {
      label: '不匿名', value: 1
    },
    {
      label: '匿名', value: 0
    }
  ]
  return complainStatus
}
// 信箱管理
export const useMailboxStatus = () => {
  const mailboxStatus = [
    {
      label: '已读不回', value: 1
    },
    {
      label: '未读', value: 0
    }
  ]
  return mailboxStatus
}
// 广告位置
export const useAdvStatus = () => {
  const advStatus = [
    {
      label: '移动端轮播图', value: 1
    },
    {
      label: 'PC端轮播图', value: 2
    }
  ]
  return advStatus
}

// 文章状态
export const useArticleStatus = () => {
  const articleStatus = [
    {
      label: '隐藏', value: 0
    },
    {
      label: '显示', value: 1
    }
  ]
  return articleStatus
}
// 通知公告类型
export const useNoticeStatus = () => {
  const noticeStatus = [
    {
      label: '通知', value: 1
    },
    {
      label: '公告', value: 2
    }
  ]
  return noticeStatus
}
// 投票管理类型
export const useTicketStatus = () => {
  const ticketStatus = [
    {
      label: '单选', value: 0
    },
    {
      label: '多选', value: 1
    }
  ]
  return ticketStatus

}

import { communityINfoApi } from '@/api/parking'
export const menuInfoApiList = (type) => {
  console.log(type);
  let menuInfoApi = [
    { label: '菜单', value: "menu" },
    { label: '按钮', value: "file" },
  ]
  return menuInfoApi
}

export const communityListApi = () => {
  const community = ref([])
  const initData = async () => {
    const res = await communityINfoApi()
    // console.log(res);
    community.value = res.data
  }
  onMounted(() => {
    initData()
  })
  return community
}
import { getAdvertisingApi } from '@/api/advertising'



export const useAdvAllList = () => {

  // 创建一个空数组
  const advList = ref([])
  // 定义一个方法
  const getAllAdvList = async () => {
    const { data } = await getAdvertisingApi()
    // console.log(data);
    advList.value = data
  }
  onMounted(() => {
    getAllAdvList()
  })

  return advList
}

// 获取广告状态
export const useAdvState = () => {
  let stateList = [
    { label: '开启', value: 1 },
    { label: '禁用', value: 0 }
  ]

  return stateList
}

// 获取广告位置
export const usePlaceState = () => {
  let placeList = [
    { label: '移动端轮播图', value: 1 },
    { label: 'PC端轮播图', value: 2 }
  ]

  return placeList
}